﻿ 

@using MvcApplication4.Models;
@model IEnumerable<Student>
@{
    ViewBag.Title = "Hierarchy";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

<h2>Hierarchy</h2>
<br /><br />

<div class="sample-panel-margin" style="width: 95%;">
    @(Html.Syncfusion().Grid<Student>("GenericListGrid")
            .Datasource(Model)
    .Caption("Student Details")
    .EnablePaging()
    .EnableSorting()
    .ShowCaption(true)
    .Column(cols =>
    {
        cols.Add(c => c.UniversityCode).HeaderText("University Code").TextAlign(Syncfusion.Mvc.Grid.TextAlignment.Right).Width(110);
        cols.Add(c => c.Title).HeaderText("Title");
        cols.Add(c => c.Duration).HeaderText("Duration").TextAlign(Syncfusion.Mvc.Grid.TextAlignment.Right).Width(80);
        cols.Add(c => c.CourseFees).HeaderText("Course Fees").TextAlign(Syncfusion.Mvc.Grid.TextAlignment.Right).Format("{0:C}").Width(90);
        cols.Add(c => c.CGPA).HeaderText("CGPA").TextAlign(Syncfusion.Mvc.Grid.TextAlignment.Right).Width(80).Format("{0:P}");
    })   
    .ChildGrid(child =>
    {
        child.ChildGridTemplate(Html.Syncfusion().Grid<Student_Details>("ChildGrid_${UniversityCode}")
        .Caption("Student Mark Details")
        .Column(c =>
        {
            c.Add(p => p.UniversityCode).HeaderText("Order ID").TextAlign(Syncfusion.Mvc.Grid.TextAlignment.Right);
            c.Add(p => p.M1).HeaderText("Mark1").TextAlign(Syncfusion.Mvc.Grid.TextAlignment.Right);
            c.Add(p => p.M2).HeaderText("Mark2").TextAlign(Syncfusion.Mvc.Grid.TextAlignment.Right);
            c.Add(p => p.M3).HeaderText("Mark3").TextAlign(Syncfusion.Mvc.Grid.TextAlignment.Right);
            c.Add(p => p.M4).HeaderText("Mark4").TextAlign(Syncfusion.Mvc.Grid.TextAlignment.Right);
        })
        .EnableSorting()
        .EnablePaging()
        .Mappers(map =>
        {
            map.Action("ChildGrid", new { UniversityCode = "${UniversityCode}" });
        })
        .ToChildGridTemplate());
    })
    .RowDataBound(row =>
    {
        if (row.Data.UniversityCode == 1001)
            row.Expanded = true;
    }))
</div>
